package art.client;

import art.client.activites.ArtUploadActivity;
import art.client.activites.ArtsListActivity;
import art.client.activites.LoginActivity;
import art.client.activites.UserArtsActivity;
import art.client.activites.UserInfoActivity;
import art.client.activites.UsersListActivity;
import art.client.places.ArtUploadPlace;
import art.client.places.ArtsListPlace;
import art.client.places.LoginPlace;
import art.client.places.UserArtsPlace;
import art.client.places.UserInfoPlace;
import art.client.places.UsersListPlace;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;

public class AppActivityMapper implements ActivityMapper {

	private ClientFactory clientFactory;

	public AppActivityMapper(ClientFactory clientFactory) {
		super();
		this.clientFactory = clientFactory;
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof LoginPlace) {
			return new LoginActivity((LoginPlace) place, clientFactory);
		} else if (place instanceof ArtsListPlace) {
			ArtsListPlace alp = (ArtsListPlace) place;
			return new ArtsListActivity(alp, clientFactory, alp.getLoginInfo());
		} else if (place instanceof ArtUploadPlace) {
			ArtUploadPlace aup = (ArtUploadPlace) place;
			return new ArtUploadActivity(clientFactory, aup.getLoginInfo());
		} else if (place instanceof UserArtsPlace) {
			UserArtsPlace uap = (UserArtsPlace) place;
			return new UserArtsActivity(clientFactory, uap.getLoginInfo());
		} else if (place instanceof UserInfoPlace) {
			UserInfoPlace uip = (UserInfoPlace) place;
			return new UserInfoActivity(clientFactory, uip.getLoginInfo());
		} else if (place instanceof UsersListPlace) {
			UsersListPlace ulp = (UsersListPlace) place;
			return new UsersListActivity(clientFactory, ulp.getLoginInfo());
		}
		return null;
	}

}
